<!DOCTYPE html>
<html lang="en" xmlns:v-bind="http://www.w3.org/1999/xhtml"
      xmlns:v-on="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>应收台账</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-store, must-revalidate">
    <meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT">
    <meta http-equiv="expires" content="-1">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
          name="viewport">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="shortcut icon" href="/dist/img/icon.png" type="image/x-icon">
    <!-- Bootstrap 3.3.6 -->
    <link rel="stylesheet" href="/dist/plugins/bootstrap/css/bootstrap.min.css">
    <!--字体-->
    <link rel="stylesheet" href="/dist/css/font-awesome.min.css">
    <!--图标-->
    <link rel="stylesheet" href="/dist/css/ionicons.min.css">
    <!--插件样式-->
    <link href="/dist/plugins/ztree/css/zTreeStyle/zTreeStyle.css" rel="stylesheet"/>

    <link rel="stylesheet" href="/dist/plugins/select2/select2.min.css">
    <link rel="stylesheet" href="/dist/plugins/fixedTable/fixed-table.css"/>
    <!--OA主样式-->
    <link rel="stylesheet" href="/dist/css/OA.min.css?t=39cd89cd">
    <link rel="stylesheet" href="/dist/css/skins/OA-skins.min.css?t=16f1e6f3">
    <style>
        .table > tbody > tr > td {
            line-height: 24px;
            max-height: 24px;
            overflow: hidden;
        }

        .left {
            width: 150px;
            float: left;
        }

        .wyui-autocomplete-panel {
            left: 180px !important;
            width: 150px;
            background: #fff;
            border: 1px solid #a0a0a0;
            border-radius: 3px;
            box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
            position: absolute;
            margin: 0px;
            padding: 0px;
            display: none;
            z-index: 9999;
            overflow: auto;
            overflow-x: hidden;
        }

        span.lineOne {
            line-height: 28px !important;
            height: 28px;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 1;
        }

        .div-td-content-more {
            position: absolute;
            height: auto;
            z-index: 999;
            line-height: 20px;
            background-color: #d3e8fd;
            padding: 8px 6px;
            border: 1px solid #e8e8ea;
            display: none;
        }

        .divCheck {
            height: 100%;
            margin-left: 5px;
            line-height: 25px;
        }

        .divCheck input {
            float: left;
            margin-top: 7px;
            margin-right: 5px;
        }

        .div-td-content-more i {
            width: 15px;
            height: 12px;
            background: url("/dist/img/more-icon.png");
            position: absolute;
            left: 50px;
            top: -12px;
        }
        .gray td {
            color: #CCCCCC !important;
        }
        .red {
            color: #fff;
            background: red;
        }

        .blue {
            color: #000;
            background-color: orange;
        }

        .ygColor {

        }

        . > tbody tr.blue:hover {
            color: black;
        }

        .fixed-table_body tr td {
            border-right: none;
            font-size: 12px;
            text-align: center;
        }

        .fixed-table_header tr th {
            border-right: none;
            background: yellow;
            font-weight: normal;
            font-size: 12px;
            text-align: center;
        }

        .duiqi {
            text-align: justify;
            display: inline-block;
            overflow: hidden;
            vertical-align: middle;
            height: 36px;
            line-height: 24px;
            width: 36px;
        }

        .content {
            padding: 8px 8px 0 8px;
        }
    </style>
</head>
<body>
<section class="content" id="app">
    <div class="oaLoad">
        <div class="loadGif" id="areaProgress"></div>
    </div>
    <div class="div-td-content-more"><i></i></div>
    <div class="left" id="inboxGroup" id="divLeft"
         style="position: fixed;background-color: white;height: 25px;overflow: hidden;z-index: 999;">
        <!--<div class="box-body no-padding box-border iframeH" style="overflow: auto;background: #f7f8fa;">-->
        <ul style="padding-top: 2px" class="ztree" id="ztree"></ul>
        <!--</div>-->
    </div>
    <div style="height: 25px;margin-bottom: 10px;">
        <!--<input type="text" id="likeSelect" class="form-controll pull-left"  style="width: 130px;height: 25px;" placeholder="请输入关键字" size="12">-->
        <!--<input type="button" class="btn oaBtn pull-left btn-sm"  style="margin-left: 10px"  value="查询" class="oaBtn" @click="search">-->
        <input type="text" placeholder="关键字" class="form-control pull-left input-sm"
               style="width: 200px;margin-left: 160px" v-model="searchParams.customerKey" id="txtParent">
        <!--<input type="text" placeholder="制作人" class="form-control pull-left input-sm"-->
        <!--style="width: 100px; margin-left: 10px;" v-model="searchParams.createUserName"-->
        <!--id="regionManagerName">-->
        <!--    <input type="text" placeholder="序列号" class="form-control pull-left input-sm"
                   style="width: 100px; margin-left: 10px;" v-model="searchParams.serialNo" id="">-->
        <button type="button" class="btn oaBtn btn-sm" style="margin-left: 10px;float: left;" @click="search">查询
        </button>
        <div class="pull-left divCheck">
            <input type="checkbox" id="cbCheck" v-model="haveSettle" @click="searchAll">显示已结清
        </div>
        <div class="pull-left divCheck">
            <input type="checkbox" v-model="cancel" @click="cancelAll">显示已作废
        </div>
        <button type="button" class="btn oaBtn btn-sm" style="float: right;" @click="exportAcount">导出应收台账</button>


    </div>
    <div class="box-body no-padding iframeH3" style="overflow: auto;" id="scrollDiv">
        <div id="progress" class="wyui-progress"></div>
        <div class="fixed-table-box head-fixed ">
            <div class="fixed-table_header-wraper">
                <table class="fixed-table_header" cellspacing="0" cellpadding="0" border="0">
                    <thead>
                    <tr>
                        <th style="width: 32px">
                            <div>序号</div>
                        </th>
                        <th style="width: 80px">
                            <div>公司</div>
                        </th>
                        <th style="width: 48px">
                            <div>客户名称</div>
                        </th>
                        <th style="width: 80px">
                            <div>合同编号</div>
                        </th>
                        <th style="width: 56px">
                            <div>品牌</div>
                        </th>
                        <th style="width: 56px">
                            <div>设备类型</div>
                        </th>
                        <th style="width: 70px">
                            <div>型号</div>
                        </th>
                        <th style="width: 140px">
                            <div>序列号</div>
                        </th>
                        <th style="width: 56px;">
                            <div>销售价格<br>(万元)</div>
                        </th>
                        <th style="width: 56px">
                            <div>付款<br>方式</div>
                        </th>
                        <th style="width: 34px">
                            <div>结清</div>
                        </th>
                        <th style="width: 34px">
                            <div>逾期</div>
                        </th>
                        <th style="width: 48px">
                            <div>区域<br>经理</div>
                        </th>
                        <th style="width: 48px">
                            <div>大区<br>经理</div>
                        </th>
                        <th style="width: 48px">
                            <div>债权<br>经理</div>
                        </th>
                        <th style="width: 48px">
                            <div>数据<br>专员</div>
                        </th>
                        <th>
                            <div>罚息<br>状态</div>
                        </th>
                        <th style="width:120px;">
                            <div>操作</div>
                        </th>
                        <th style="width:17px;"></th>

                    </tr>
                    </thead>
                </table>
            </div>
            <div class="fixed-table_body-wraper iframeFixed">
                <table class="fixed-table_body table-hover" cellspacing="0" cellpadding="0" border="0"
                       style="width: 100%;">
                    <tbody id="tbList">
                    <tr v-for="(item,i) in list.main" :class="item.auditFlag==3?'gray':''">
                        <td class="td-tanZongStyle-line" style="width: 32px">{{i+1}}</td>
                        <td class="td-tanZongStyle-line" style="width: 80px"><span
                                class="lineOne">{{item.seller}}</span></td>
                        <td style="width: 48px;">
                            <span style="color:#2a8cec;cursor: pointer;" @click="goDetail('look',i)" class="oa-name">
                            {{item.buyer}}</span>
                        </td>
                        <td class="td-tanZongStyle-line" style="width: 80px"><span class="lineOne"
                        >{{item.contractNo=='-'?'查看':item.contractNo}}</span>
                            <!--<td @click="goDetail(item.id,'look')" style="color: #2a8cec;cursor: pointer;">-->
                            <!--201805451545-->
                            <!--</td>-->
                        <td class="td-tanZongStyle-line" style="width: 56px"><span>{{reduce(item.brandName)}}</span>
                        </td>
                        <td class="td-tanZongStyle-line" style="width: 56px"><span
                                class="lineOne"> {{item.deviceType}}</span></td>
                        <td class="td-tanZongStyle-line" style="width: 70px"><span
                                class="lineOne">{{item.modelName}}</span></td>
                        <td class="td-tanZongStyle-line" style="width: 140px"><span
                                class="lineOne">{{item.serialNo}}</span></td>
                        <td class="td-tanZongStyle-line" style="width: 56px">{{fmoney(item.salesPrice/10000)}}</td>
                        <td class="td-tanZongStyle-line" style="width: 56px">
                    <span v-if="item.buyType=='融资租赁打包'" class="lineOne">
                        打包
                    </span>
                            <span v-else>
                        {{reduce(item.buyType)}}
                    </span>

                        </td>
                        <td class="td-tanZongStyle-line" style="width: 34px">{{item.haveSettle=='1'?'是':''}}</td>
                        <td class="td-tanZongStyle-line"
                            :class="item.haveOverdue=='1'&&item.auditFlag!=3?'red':item.haveOverdue=='2'&&item.auditFlag!=3?'blue':'ygColor'"
                            style="width: 34px">{{item.haveOverdue=='1'?'是':'否'}}
                        </td>
                        <td class="td-tanZongStyle-line" style="width: 48px"><span>{{item.takeOverManager}}</span></td>
                        <td class="td-tanZongStyle-line" style="width: 48px"><span>{{item.bigRegionManagerName}}</span>
                        </td>
                        <td class="td-tanZongStyle-line" style="width: 48px"><span>{{item.creditManagerName}}</span>
                        </td>
                        <td class="td-tanZongStyle-line" style="width: 48px"><span>{{item.dataOfficerName}}</span></td>
                        <td class="td-tanZongStyle-line" v-html="convertAuditFlagToName(item)"></td>
                        <td class="td-tanZongStyle-line" style="width: 130px;">
                            <!--<a href="javascript:void(0);" @click="goDetail(item.id,'look')">&nbsp;查看&nbsp;</a>-->
                            <a href="javascript:void(0);" @click="goDetail('edit',i)"
                               v-if="isShowBtn('accountReceivableEdit')">&nbsp;编辑&nbsp;</a>
                            <a href="javascript:void(0);" v-else style="color:#ddd;cursor: no-drop">&nbsp;编辑&nbsp;</a>
                            <a href="javascript:void(0);" @click="goDetailSend('edit',i)"
                               v-if="isShowBtnSend(item.id,'accountSenderEdit')">&nbsp;发送短信&nbsp;</a>
                            <a href="javascript:void(0);" v-else style="color:#ddd;cursor: no-drop">&nbsp;发送短信&nbsp;</a>
                            <a href="javascript:void(0);"
                               v-if="item.interestFreeAuditFlag=='0'&&item.interestFreeAuditId==userId"
                               @click="goApply(item.id,item.buyType,'sh')">&nbsp;审核&nbsp;</a>
                            <a href="javascript:void(0);" v-else style="color:#ddd;cursor: no-drop">&nbsp;审核&nbsp;</a>
                            <!--<a href="javascript:void(0);" @click="goUploadFiles('edit',i)">&nbsp;结清&nbsp;</a>-->

                            <!--<a href="javascript:void(0);" v-if="isShowBtn('accountReceivableEdit')&&item.interestFreeAuditFlag=='1'&&item.applyNameId==userId&&item.exempt!='1'" @click="goInterestFree(item.id,item.buyType)"-->
                            <!--&gt;&nbsp;免罚息&nbsp;</a>-->
                            <!--<a href="javascript:void(0);" v-else style="color:#ddd;cursor: no-drop">&nbsp;免罚息&nbsp;</a>-->
                            <!--&lt;!&ndash;<a href="javascript:void(0);" v-if="item.applyNameId==userId||isShowBtnSend(item.id,'lookList')"  @click="goApply(item.id,item.buyType,'ck')">&nbsp;查看&nbsp;</a>&ndash;&gt;-->
                            <!--<a href="javascript:void(0);" v-else style="color:#ddd;cursor: no-drop">&nbsp;查看&nbsp;</a>-->

                        </td>
                    </tr>
                    </tbody>
                </table>
            </div>
        </div>
        <!--<table class="table text-center ">-->
        <!--<thead>-->
        <!--<tr>-->
        <!--<th style="width: 37px">序号</th>-->
        <!--<th style="width: 85px">公司</th>-->
        <!--<th style="width: 53px">客户名称</th>-->
        <!--<th style="width: 117px">合同编号</th>-->
        <!--<th style="width: 61px">品牌</th>-->
        <!--<th style="width: 61px">设备类型</th>-->
        <!--<th style="width: 75px">型号</th>-->
        <!--<th style="width: 80px">序列号</th>-->
        <!--<th style="width: 80px;">销售价格(元)</th>-->
        <!--<th style="width: 85px">付款方式</th>-->
        <!--<th style="width: 39px">结清</th>-->
        <!--<th style="width: 39px">逾期</th>-->
        <!--<th style="width: 53px">区域经理</th>-->
        <!--<th style="width: 53px">大区经理</th>-->
        <!--<th style="width: 53px">债权经理</th>-->
        <!--<th style="width: 53px">数据专员</th>-->
        <!--<th style="width:120px">操作</th>-->
        <!--</tr>-->
        <!--</thead>-->
        <!--<tbody id="tbList">-->
        <!--<tr v-for="(item,i) in list.main"-->
        <!--&gt;-->
        <!--<td>{{i+1}}</td>-->
        <!--<td class="td-tanZongStyle-line"><span>{{item.seller}}</span></td>-->
        <!--<td  style="background-color: white;"  class="td-tanZongStyle-line"><span-->
        <!--style="color:#2a8cec;cursor: pointer;" @click="goDetail('look',i)">{{item.buyer}}</span></td>-->
        <!--<td class="td-tanZongStyle-line"><span-->
        <!--&gt;{{item.contractNo=='-'?'查看':item.contractNo}}</span>-->
        <!--&lt;!&ndash;<td @click="goDetail(item.id,'look')" style="color: #2a8cec;cursor: pointer;">&ndash;&gt;-->
        <!--&lt;!&ndash;201805451545&ndash;&gt;-->
        <!--&lt;!&ndash;</td>&ndash;&gt;-->
        <!--<td class="td-tanZongStyle-line"><span>{{item.brandName}}</span></td>-->
        <!--<td class="td-tanZongStyle-line"><span>{{item.deviceType}}</span></td>-->
        <!--<td class="td-tanZongStyle-line"><span>{{item.modelName}}</span></td>-->
        <!--<td class="td-tanZongStyle-line"><span class="lineOne">{{item.serialNo}}</span></td>-->
        <!--<td>{{fmoney(item.salesPrice)}}</td>-->
        <!--<td class="td-tanZongStyle-line">-->
        <!--<span v-if="item.buyType=='融资租赁打包'" class="lineOne">-->
        <!--融资租赁(打包)-->
        <!--</span>-->
        <!--<span v-else class="lineOne">-->
        <!--{{item.buyType}}-->
        <!--</span>-->

        <!--</td>-->
        <!--<td>{{item.haveSettle=='1'?'是':'否'}}</td>-->
        <!--<td :class="item.haveOverdue=='1'?'red':item.haveOverdue=='2'?'blue':'ygColor'">{{item.haveOverdue=='1'?'是':'否'}}</td>-->
        <!--<td class="td-tanZongStyle-line"><span >{{item.takeOverManager}}</span></td>-->
        <!--<td class="td-tanZongStyle-line"><span >{{item.bigRegionManagerName}}</span></td>-->
        <!--<td class="td-tanZongStyle-line"><span>{{item.creditManagerName}}</span></td>-->
        <!--<td class="td-tanZongStyle-line"><span >{{item.dataOfficerName}}</span></td>-->
        <!--<td style="background-color: white;">-->
        <!--&lt;!&ndash;<a href="javascript:void(0);" @click="goDetail(item.id,'look')">&nbsp;查看&nbsp;</a>&ndash;&gt;-->
        <!--<a href="javascript:void(0);" @click="goDetail('edit',i)" v-if="isShowBtn('accountReceivableEdit')">&nbsp;编辑&nbsp;</a>-->
        <!--<a href="javascript:void(0);" v-else style="color:#ddd;cursor: no-drop">&nbsp;编辑&nbsp;</a>-->
        <!--<a href="javascript:void(0);" @click="goDetailSend('edit',i)"-->
        <!--v-if="isShowBtnSend(item.id,'accountSenderEdit')">&nbsp;发送短信&nbsp;</a>-->
        <!--<a href="javascript:void(0);" v-else style="color:#ddd;cursor: no-drop">&nbsp;发送短信&nbsp;</a>-->
        <!--</td>-->
        <!--</tr>-->
        <!--</tbody>-->
        <!--</table>-->

    </div>
    <div class="oa-pager text-center" style="margin-top: 5px;">
        共
        <span id="allCount"> 0 </span>条记录&nbsp;&nbsp;&nbsp;
        <span id="nowPage"> 1 </span>/<span id="allPage">1</span>&nbsp;&nbsp;&nbsp;
        <span class="oa-pager-button" id="first">首页</span>
        <span class="oa-pager-button" id="prev">上一页</span>
        <span class="oa-pager-button" id="next">下一页</span>
        <span class="oa-pager-button" id="last">尾页</span>
    </div>
</section>
<!--JQ-->
<script src="https://file.ggxqce.com/web/jquery-2.2.3.min.js"></script>
<!--插件JS-->
<script src="https://file.ggxqce.com/web/bootstrap.min.js"></script>
<!--框架已定义 JS-->
<script src="/dist/js/app_iframe.js?t=7e54a132"></script>
<!--oa自定义  JS-->
<script src="/dist/js/oa.js?t=558d0414"></script>

<!--ztree组件所需js-->
<script type="text/javascript" src="/dist/plugins/ztree/js/jquery.ztree.all-3.5.min.js"></script>
<script type="text/javascript" src="/dist/plugins/ztree/js/jquery.ztree.exhide-3.5.js"></script>


<script src="https://file.ggxqce.com/web/vue.min.js"></script>
<script src="/dist/plugins/select2/select2.full.min.js"></script>
<script type="text/javascript" src="/dist/plugins/lhgdialog/lhgdialog.min.js?self=true"></script>
<script src="/dist/plugins/fixedTable/fixed-table.js"></script>
<script>
    $(function () {
        $("body").on("click", ".lineOne,.lineTwo", function (e) {
            if ($(".div-td-content-more").is(":hidden")) {
                var text = $(this).text();
                if (text != "") {
                    text = "<i></i>" + text;
                    $(".div-td-content-more").html(text).css({
                        "width": $(this).outerWidth() + 80 + "px",
                        "left": $(this).offset().left - 6,
                        "top": ($(this).offset().top + $(this).outerHeight()) + "px"
                    }).show();
                    e.stopPropagation();
                }
            } else {
                $(".div-td-content-more").hide();
            }
        });
        $("body").on("click", ".div-td-content-more", function (e) {
            e.stopPropagation();
        });
        $("body").on("click", function () {
            $(".div-td-content-more").hide();
        });
    });
</script>
<script type="text/javascript">
    var zTreeCallback = {
        showIcon: function (treeId, treeNode) {
            return treeNode.isParent;
        },
        onClick: function (event, treeId, treeNode) {
            // console.log(treeNode)
            app.searchParams.companyId = treeNode.id;
            app.search();
            app.getTreeData();

            // var tree = $.fn.zTree.getZTreeObj('ztree');
            // //获取 zTree 的全部节点数据将节点数据转换为简单 Array 格式
            // var nodes = tree.transformToArray(tree.getNodes());
            // for (var i = 0; i < nodes.length; i++) {
            //
            //     tree.expandNode(nodes[i], false, true, false)
            //
            // }


        },
        beforeClick: function (treeId, treeNode, clickFlag) {
            if (treeNode.level == 0) {
                return false;
            }
        },
        zTreeOnExpand(event, treeId, treeNode) {
//                $("#inboxGroup").css("height","100%")
            $("#inboxGroup").animate({height: "100%"}, 200)
        },
        zTreeOnCollapse(event, treeId, treeNode) {
            $("#inboxGroup").css("height", "25px")
        }
    };
    var zTreeSetting = {
        view: {
            showIcon: zTreeCallback.showIcon
        },
        data: {
            simpleData: {
                enable: true
            },
            keep: {
                parent: true
            }
        },
        callback: {
            onClick: zTreeCallback.onClick,
            beforeClick: zTreeCallback.beforeClick,
            beforeCollapse: zTreeCallback.zTreeOnCollapse,
            beforeExpand: zTreeCallback.zTreeOnExpand
        }
    };

</script>
<script type="text/javascript">
    function refresh() {
        $.wyui.page.getByPage();
    }

    var app = new Vue({
            el: '#app',
            data: {
                rightOp: [],//权限列表
                sendList: [],
                lookList: [],
                userId: getCurrentUser().id,
                currentUser: getCurrentUser(),
                haveSettle: false,
                cancel: false,
                roleName: getCurrentUser().roleName,
                list: {
                    // verifying: '',
                    // pass: '',
                    main: [],
                },
                searchParams: {
                    userId: $.wyui.page.urlParams.userId ? $.wyui.page.urlParams.userId : getCurrentUser().id,
                    customerKeyId: '',
                    createUserId: '',
                    customerKey: '',
                    createUserName: '',
                    auditFlag: 1,
                    companyId: '',
                    haveSettle: 0,
                    cancel: ''
                },
                searchParamsAll: {
                    userId: $.wyui.page.urlParams.userId ? $.wyui.page.urlParams.userId : getCurrentUser().id,
                    haveSettle: 1
                },
                cancelParamsAll: {
                    userId: $.wyui.page.urlParams.userId ? $.wyui.page.urlParams.userId : getCurrentUser().id,
                    cancel: 3
                }
            },
            methods: {
                isShowBtn: function (eName) {
                    if (($.inArray(eName, this.rightOp) > -1)) {
                        return true;
                    } else {
                        return false;
                    }
                },
                isShowBtnSend: function (id, accountSenderEdit) {
                    if (accountSenderEdit == 'lookList') {
                        if ($.inArray(id, this.lookList) > -1) {
                            return true;
                        } else {
                            return false;
                        }
                    } else {
                        console.log(accountSenderEdit)
                        if ($.inArray(id, this.sendList) > -1
                            && ($.inArray(accountSenderEdit, this.rightOp) > -1)) {
                            return true;
                        } else {
                            return false;
                        }
                    }

                },
                goUploadFiles: function (type, i) {
                    var that = this;
                    var id = that.list.main[i].id;

                    var H = $(window).height();
                    top.$.dialog({
                        content: 'url:apply/accountReceivable/uploadFiles.html?contractId=' + id,
                        title: '附件管理',
                        width: 700,
                        height: 580,
                        max: false,
                        min: false,
                        lock: true
                    });
                },
                reduce: function (name) {
                    switch (name) {
                        case "利勃海尔":
                            return "海尔";
                            break;
                        case "约翰迪尔":
                            return "迪尔";
                            break;
                        case "融资租赁":
                            return "融资";
                            break;
                        case "融资租赁(打包)":
                            return "打包";
                            break;
                        case "内部分期":
                            return "分期";
                            break;
                        default :
                            return name;
                            break;
                    }
                },
                getTreeData: function () {
                    var that = this;
                    $.wyui.postMethod(urlConfig.system.system.getCompanyTreeForXSTZ, {companyId: getCurrentUser().companyId}, function (nodes) {
                        console.log(nodes)

                        for (var i = 0; i < nodes.length; i++) {

                            if (nodes[i].name == '重庆迎风') {
                                nodes.splice(i, 1);
                            }
                            if (i != 0) {
                                nodes[i].open = false
                            }

                        }

                        that.treeObj = $.fn.zTree.init($("#ztree"), zTreeSetting, nodes);
                        var treeObj = $.fn.zTree.getZTreeObj("ztree");
                        var nodes = treeObj.getNodes();
                        // that.treeObj.expandAll(false)
                        console.log(nodes)
                        $("#inboxGroup").animate({height: "25px"}, 10)
                        // if (nodes[0].children[0]) {
                        //     treeObj.selectNode(nodes[0].children[0]);
                        //     that.searchParams.companyId = nodes[0].children[0].id;
                        //     that.search();
                        // }
                        //
                    });
                },
                goApply: function (id, buyType, lookType) {
                    var title;
                    if (lookType == 'sh') {
                        title = '免息申请审核'
                    } else {
                        title = '免息申请审核详情'
                    }
                    var H = $(window).height() - 50;
                    top.$.dialog({
                        content: 'url:/page/apply/accountReceivable/InterestFreeSq.html?id=' + id + '&buyType=' + buyType + '&pageType=look' + "&shOrSq=sh" + '&lookType=' + lookType,
                        title: title,
                        width: 1300,
                        height: H,
                        max: false,
                        min: false,
                        lock: true
                    });
                },
                convertAuditFlagToName: function (item) {
                    switch (item.interestFreeAuditFlag) {
                        case "-1":
                            return "未提交";
                            break;
                        case "0":
                            if (item.interestFreeAuditId == getCurrentUser().id) {
                                return "<span style='color:red;' class='lineOne'>待-" + item.interestFreeAuditName + "-审核</span>";
                            } else {
                                return "<span class='lineOne'>待-" + item.interestFreeAuditName + "-审核</span>";
                            }
                            break;
                        case "1":
                            return "已通过";
                            break;
                        case "2":
                            if (item.createUserId == getCurrentUser().id) {
                                return "<span style='color:red;'>已驳回</span>";
                            } else {
                                return "已驳回";
                            }
                            break;
                        case "3":
                            return "已作废";
                            break;
                        default :
                            break;
                    }
                },

                fmoney: function (s, n) {
                    n = n > 0 && n <= 20 ? n : 2;
                    s = parseFloat((s + "").replace(/[^\d\.-]/g, "")).toFixed(n) + "";
                    var l = s.split(".")[0].split("").reverse(), r = s.split(".")[1],
                        t = "";
                    for (i = 0; i < l.length; i++) {
                        t += l[i] + ((i + 1) % 3 == 0 && (i + 1) != l.length ? "," : "");
                    }
                    return t.split("").reverse().join("") + "." + r;
                },

                exportAcount: function () {

                    var that = this;
                    var H = $(window).height() - 50;
                    $.dialog({
                        content: 'url:/page/apply/accountReceivable/exportDetail.html',
                        title: '应收台账导出字段',
                        width: 1000,
                        height: 700,
                        max: false,
                        min: false,
                        lock: true
                    });
                },
                goDetail: function (type, i) {
                    top.closeTabByPageId("contractDetail");
                    var that = this;
                    var id = that.list.main[i].id;
                    var buyType = that.list.main[i].buyType;
                    var condition = '?id=' + id + '&buyType=' + buyType;
                    if (type == 'look') {
                        condition += '&pageType=look';
                        top.addTabs({
                            id: 'accountReceivable' + id,
                            title: '应收台账详情页',
                            close: true,
                            noblockUI: true,
                            url: 'apply/accountReceivable/detail.html' + condition
                        });
                        /* var H = $(window).height() - 50;
                         top.$.dialog({
                         content: 'url:/page/apply/accountReceivable/detail.html?pageType=' + type + "&id=" + id,
                         title: '应收台账详情页',
                         width: 904,
                         height: H,
                         max: false,
                         min: false,
                         lock: true
                         });*/
                    }
                    if (type == 'edit') {
                        console.log(that.roleName);
                        console.log(that.roleName.indexOf('应收') != -1)
                        if (that.roleName.indexOf('应收') != -1) {
                            condition += "&pageType=edit&&editUser=1";
                        } else {
                            condition += "&pageType=edit&&editUser=0";
                        }
                        top.addTabs({
                            id: 'accountReceivable' + id,
                            title: '应收台账详情页',
                            close: true,
                            noblockUI: true,
                            url: 'apply/accountReceivable/detail.html' + condition
                        });
                        /*  var H = $(window).height() - 50;
                         top.$.dialog({
                         content: 'url:/page/apply/accountReceivable/detail.html?pageType=' + type + "&id=" + id,
                         title: '应收台账详情页',
                         width: 904,
                         height: H,
                         max: false,
                         min: false,
                         lock: true
                         });*/
                    }
                },
                goDetailSend: function (type, i) {
                    var that = this;
                    var id = that.list.main[i].id;

                    var H = $(window).height();
                    top.$.dialog({
                        content: 'url:apply/accountReceivable/senderMessage.html?id=' + id,
                        title: '应收台账短信页',
                        width: 700,
                        height: 580,
                        max: false,
                        min: false,
                        lock: true
                    });
                },

                search: function () {
                    $.wyui.page.queryParams.requestPage = 1;
                    this.searchParams.haveSettle = "";
                    $.extend($.wyui.page.queryParams, trimRN(this.searchParams));
                    console.log($.wyui.page.queryParams);
                    $.wyui.page.getByPage();
                },

                searchAll: function () {
                    if (!this.haveSettle) {
                        $.extend($.wyui.page.queryParams, this.searchParamsAll);
                    } else {
                        $.extend($.wyui.page.queryParams, this.searchParams);
                    }
                    $.wyui.page.queryParams.requestPage = 1;
                    $.wyui.page.getByPage();
                },
                cancelAll: function () {
                    if (!this.cancel) {
                        $.extend($.wyui.page.queryParams, this.cancelParamsAll);
                    } else {
                        $.extend($.wyui.page.queryParams, this.searchParams);
                    }
                    $.wyui.page.queryParams.requestPage = 1;
                    $.wyui.page.getByPage();
                }
            },
            mounted:
                function () {
                    //查询用户有哪些权限
                    var that = this;
                    $.wyui.postMethod(urlConfig.system.rightOp.getRightOpByUserId, {userId: getCurrentUser().id}, function (rightOp) {
                        for (var i = 0; i < rightOp.length; i++) {
                            that.rightOp.push(rightOp[i].eName);
                        }

                        console.log("权限列表如下：")
                        console.log(that.rightOp);
                    });
                    that.getTreeData();
                    $.wyui.postMethod(urlConfig.receivable.getRepaymentDate, {}, function (data) {
                        for (var i = 0; i < data.length; i++) {
                            that.sendList.push(data[i].mainId);
                        }

                        console.log("权限列表如下：")
                        console.log(that.rightOp);
                    });
                    $.wyui.postMethod(urlConfig.receivable.interestLook, {userId: getCurrentUser().id}, function (data) {
                        for (var i = 0; i < data.length; i++) {
                            that.lookList.push(data[i].mainId);
                        }
                    });


                }
        })
    ;
    //分页
    $.wyui.page.dataUrl = server.ip + urlConfig.receivable.selectContractAccountList;
    $.wyui.page.queryParams.pageType = $.wyui.page.urlParams.pageType;
    $.wyui.page.queryParams.load = true;
    $.wyui.page.queryParams.userId = $.wyui.page.urlParams.userId ? $.wyui.page.urlParams.userId : getCurrentUser().id;
    $.wyui.page.queryParams.auditFlag = 1;
    $.wyui.page.queryParams.haveDelivery = 1;
    $.wyui.page.queryParams.haveSettle = 0;
    $.extend($.wyui.page.queryParams);
    $.wyui.page.getByPage_callback = function (r) {
        //console.log(r)
        // app.list.verifying = r.verifying;
        // app.list.pass = r.pass;
        app.list.main = r;
        //console.log(app.list.main)
        document.getElementById("scrollDiv").scrollTop = 0;
    };
    $.wyui.page.getByPage_scroll_callback = function (list) {
        if (list.length < 30) {
            isLoad = false;
        } else {
            for (var i = 0; i < list.length; i++) {
                app.list.push(list[i]);
            }
            isLoad = true;
        }
    };
    $(function () {
        $("#txtParent").autoComplete({
            url: server.ip + urlConfig.contract.getContractBuyer,
            render: function (r, panel) {
                for (var i = 0; i < r.length; i++) {
                    $("<li></li>").data("autoComplete",
                        r[i]).html("<a>" + r[i].customerName + "&nbsp;&nbsp;&nbsp;" +
                        "(" + "&nbsp;" + r[i].customerTel + ") " + "</a>")
                        .appendTo(panel);
                }
            },
            selected: function (r) {
                app.searchParams.customerKey = r.customerName;
                return false;
            },
            height: 210,
            width: 300
        })
        $("#regionManagerName").autoComplete({
            url: server.ip + urlConfig.system.user.getTop10ByNameUser,
            render: function (users, panel) {
                for (var i = 0; i < users.length; i++) {
                    $("<li></li>").data("autoComplete",
                        users[i]).html("<a>" + users[i].name + "&nbsp;&nbsp;&nbsp;" +
                        "(" + "&nbsp;" + users[i].companyName + "-" + users[i].departName + "-" + users[i].roleName + "&nbsp;" + ") " + "</a>")
                        .appendTo(panel);
                }
            },
            selected: function (user) {
                app.searchParams.regionManagerKeyId = user.id;
                app.searchParams.createUserName = user.name;
                return false;
            },
            height: 210,
            width: 220
        });

    });
</script>
<script>
    //初始化FixedTable
    $(".fixed-table-box").fixedTable();
</script>
</body>
</html>